#!/bin/bash -e
# only support snpsift snpeff VEP annovar combined result

function info() {
echo Usage: `basename $0` in.vcf
exit 65
}

while getopts  ":i:b:p:" opts
do
        case  $opts  in
        i) interval=$OPTARG;;
		b) asemmbly=$OPTARG;;
		p) out_prefix=$OPTARG;;
		*) info;;
        esac
done
shift $(($OPTIND - 1))

if [ -z $1 ]; then info; fi


. $var

echo basic info 
cat $1 |grep -v '^##'|cut -f1-5,7 |sed '1s/\#CHROM\tPOS/CHROM\tGRCh37 POS/' >$out_prefix.vcf_basic.txt

# cat $1 |java -jar $snpsift extractField ../$1 "GEN[0].DP" > 1.dp.txt

echo custom made info 
cat $1 |java -jar $snpsift extractField - "GEN[0].DP" af VARTYPE HOM HET STRAND cytoBand GENE Gene.refGene GeneDetail.refGene CDS ExonicFunc.refGene AAChange.refGene dbNSFP_SIFT_score ljb23_sift dbNSFP_Polyphen2_HVAR_score ljb23_pp2hvar ljb23_mt dbNSFP_Ensembl_transcriptid dbNSFP_Interpro_domain dbNSFP_Uniprot_acc LOF cosmic70 clinvar_20150629 |sed '1s/\#GEN\[0\]\.DP/DP/' >$out_prefix.some_info.txt


paste $out_prefix.vcf_basic.txt $out_prefix.some_info.txt > $out_prefix.simple_info.txt

tab2xls.pl $out_prefix.simple_info.txt $out_prefix.simple_info.xls

format_jxl.sh $out_prefix.simple_info.xls $out_prefix.simple_info.jxl.xls

. $cmd_done